package com.example.demo.confi;

import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;

/**
 * Created by Administrator on 2017-6-29.
 */
public class Jo extends JSONObject {

    /**
     * 自动部署ip地址
     *
     * @param test_ip
     * @return
     */
    public JSONObject ip(String test_ip) {
        put("test_ip", test_ip);
        return this;
    }


    static Mo create(String tag, String pro, String url, String sub_model, String daily_deploy, String clean) {

        int i = url.lastIndexOf(".");
        int len = url.length();
        Mo j = new Mo();
        j.put("url", url);
        j.put("pro", pro);
        j.put("pak", tag);
        j.put("pub", 0);
        if (StringUtils.isNotBlank(sub_model))
            j.put("sub_model", sub_model);
        if (StringUtils.isNotBlank(daily_deploy))
            j.put("daily_deploy", daily_deploy);
        j.put("test_ip", 101);
        j.put("clean", clean);
        j.put("file", url.substring(url.lastIndexOf("/") + 1));
        return j;
    }

    static Jo create_pub(String job_name, String file, String module, String sub_model) {


        Jo j = new Jo();

        j.put("file", file);
        j.put("job_name", job_name);
        j.put("module", module);
        j.put("pub", 1);
        if (StringUtils.isNotBlank(sub_model))
            j.put("sub_model", sub_model);
        j.put("clean", "true");

        return j;
    }

}
